package com.fizzkai.p2p.mgrsite.listener;

import com.fizzkai.p2p.bussness.service.ISystemAccountService;
import com.fizzkai.p2p.core.service.ILoginInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

@Component
public class InitAdminListener implements ApplicationListener<ContextRefreshedEvent> {
    @Autowired
    private ILoginInfoService loginInfoService;
    @Autowired
    private ISystemAccountService systemAccountService;


    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        // 所有 bean 已经 加载完毕的 事件
        System.out.println("-------------------华丽分割线----------------------");
        System.out.println(loginInfoService);
        loginInfoService.initAdmin();   // 里面做判断 有没有管理员
        // 创建 系统账户
        systemAccountService.initSystemAccount();

    }
}
